package com.webtest.demo;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import com.webtest.dataprovider.ExcelDataProvider;

public class ZiYuanTest extends com.webtest.core.ZiYuanBase{

	@DataProvider(name="knowledge")
	public Object[][] getKnowledgeData() throws Exception{
		return new ExcelDataProvider().getTestDataByExcel("D:\\test\\auto\\data\\knowledge2.xlsx", "Sheet1");
	}
	@DataProvider(name="question")
	public Object[][] getQuestionData() throws Exception{
		return new ExcelDataProvider().getTestDataByExcel("D:\\test\\auto\\data\\question.xlsx", "Sheet1");
	}
	@DataProvider(name="sort")
	public Object[][] getSortData() throws Exception{
		return new ExcelDataProvider().getTestDataByExcel("D:\\test\\auto\\data\\sort.xlsx", "Sheet1");
	}
	//文档预览
	@Test
	public void test12() {
		webtest.click("id=menu_list_num124");
		webtest.click("xpath=//a[ends-with(@onclick,'(0,0)')]");
	}
	//上传文件（关闭）
	@Test
	public void test13() {
		webtest.click("id=menu_list_num124");
		webtest.click("xpath=//button[text()=' 上传文件']");
		webtest.click("xpath=//button[text()='关闭']");
	}
	//向管理层共享文档
	@Test
	public void test14() {
		webtest.click("id=menu_list_num124");
		webtest.click("xpath=//input[starts-with(@id,'seltablecheck_')]");
		webtest.click("xpath=//button[@click='sharefile']");
		webtest.click("xpath=//input[@xname='管理层']");
		webtest.click("xpath=//input[@value='确定']");
	}
	//取消共享
	@Test
	public void test15() {
		webtest.click("id=menu_list_num124");
		webtest.click("xpath=//input[starts-with(@id,'seltablecheck_')]");
		webtest.click("xpath=//button[@click='qxsharefile']");
	}
	//移动文档
	@Test
	public void test16() {
		webtest.click("id=menu_list_num124");
		webtest.click("xpath=//input[starts-with(@id,'seltablecheck_')]");
		webtest.click("xpath=//button[@click='movefile']");
		webtest.click("xpath=//li[text()='图片']");
		webtest.click("id=confirm_btn1");
	}
	//查看所有文档
	@Test
	public void test17() {
		webtest.click("id=menu_list_num124");
		webtest.click("xpath=//button[@click='genmu']");
	}
	//按条件搜索知识信息
	@Test
	public void test18() {
		webtest.click("id=menu_list_num134");
		webtest.click("xpath=//button[@click='genmu']");
		webtest.type("xpath=//input[starts-with(@id,'key_')]", "标题1");
		webtest.click("xpath=//button[@click='search']");
	}
	//查看"知识"详情
	@Test
	public void test19() {
		webtest.click("id=menu_list_num134");
		webtest.click("xpath=//a[@onclick='openxiangs('知识','knowledge',3)']");
	}
	//删除第一条知识
	@Test
	public void test20() {
		webtest.click("id=menu_list_num134");
		webtest.click("xpath=//td[@row='0' and @cell='0']");
		webtest.click("xpath=//button[starts-with(@id,'del_')]");
		webtest.click("id=confirm_btn1");
	}
	//双击查看"官网知识"
	@Test
	public void test21() throws Exception {
		webtest.click("id=menu_list_num135");
		webtest.doubleClick("xpath=//ul[@oi='0']");
	}
	//查看题目详情并关闭
	@Test
	public void test22() {
		webtest.click("id=menu_list_num135");
		webtest.click("xpath=//a[@oi='0']");
		webtest.click("xpath=//li[text()='详情']");
		webtest.click("id=showmenu");
		webtest.click("xpath=//li[text()='关闭']");
	}
	//批量新增"知识"
	@Test(dataProvider="knowledge")
	public void testPublishKnowledge(String title,String typeid) {
		webtest.click("id=menu_list_num134");
		webtest.click("xpath=//button[@click='adds']");
		webtest.enterFrame(0);
		webtest.type("xpath=//input[@type='text']", title);
		webtest.selectByValue("name=typeid",typeid);
		webtest.click("id=AltS");	
	}

	//批量新增题库
	@Test(dataProvider="question")
	public void testAdd(String typeid,String title,String answer) {
		webtest.click("id=menu_list_num135");
		webtest.click("xpath=//button[@click='adds']");
		webtest.enterFrame(0);
		webtest.selectByValue("name=typeid", typeid);
		webtest.type("name=title", title);
		webtest.type("name=ana", "a");
		webtest.type("name=anb", "b");
		webtest.type("name=answer", answer);
		webtest.click("id=AltS");
	}
	//批量新增题库分类
	@Test(dataProvider="sort")
	public void testAddSort(String name) {
		webtest.click("id=menu_list_num135");
		webtest.click("xpath=//a[@titlt='新增']");
		webtest.type("name=name", name);
		webtest.click("xpath=//button[starts-with(@id,'save_')]");
	}
}
